﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace SplunkLibrary.Configuration
{
    public class WriterConfiguration : ConfigurationSection
    {
        private static WriterConfiguration _instance;

        static WriterConfiguration()
        {
            _instance = (WriterConfiguration) ConfigurationManager.GetSection("splunkWriter");
        }

        
    }

    public class SplunkHostConfigHolder
    {
        public string Name { get; set; }
        public string Address { get; set; }
        public int Port { get; set; }
    }


    public class SplunkHostsCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new SplunkHostConfig();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((SplunkHostConfig)element).Name;
        }
    }

    
    public class SplunkHostConfig : ConfigurationElement
    {
        [ConfigurationProperty("name", IsRequired=true,IsKey=true)]
        public string Name
        {
            get { return (string)this["name"]; }
            set { this["name"] = value; }
        }


        [ConfigurationProperty("address", IsRequired = true)]
        public string Address
        {
            get { return (string)this["address"]; }
            set { this["address"] = value; }
        }

        [ConfigurationProperty("port",IsRequired=true)]
        public int Port
        {
            get { return (int)this["port"]; }
            set { this["port"] = value; }
        }
    }
}
